package com.lzm.ydpt.mvp.presenterimpl;

import com.byt.framlib.basemvp.BasePresenter;
import com.byt.framlib.basemvp.basebean.BaseResponseBean;
import com.byt.framlib.basemvp.boby.FormBodys;
import com.byt.framlib.basemvp.exception.ApiException;
import com.byt.framlib.basemvp.listener.OnLoadingErrorListener;
import com.byt.framlib.basemvp.listener.OnLoadingProgressListener;
import com.lzm.ydpt.entity.UserInfo;
import com.lzm.ydpt.module.order.activity.UserMainActivity;
import com.lzm.ydpt.module.riding.activity.RidingMainActivity;
import com.lzm.ydpt.module.riding.fragment.RidingMineFragment;
import com.lzm.ydpt.mvp.api.ProgressSubscriber;
import com.lzm.ydpt.mvp.contract.PtMainContract;
import com.lzm.ydpt.mvp.modelimpl.PtMainModelImpl;


/**
 * 类名称：MainPresenterImpl
 * 类描述：代理实现
 */
public class PtMainPresenterImpl extends BasePresenter implements PtMainContract.Presenter {

    private PtMainContract.View mView;
    private PtMainContract.Model mModel;

    public PtMainPresenterImpl(RidingMainActivity context) {
        super(context);
        this.mView = context;
        this.mModel = new PtMainModelImpl();
    }

    public PtMainPresenterImpl(UserMainActivity context) {
        super(context);
        this.mView = context;
        this.mModel = new PtMainModelImpl();
    }

    public PtMainPresenterImpl(RidingMineFragment context) {
        super(context.getContext());
        this.mView = context;
        this.mModel = new PtMainModelImpl();
    }

    @Override
    public void getUserInfo(FormBodys formBodys) {
        mManager.http(mModel.onUserInfo(formBodys), getLifecycleProvider(), new ProgressSubscriber<>(mContext, new OnLoadingProgressListener<UserInfo>() {
            @Override
            public void onLoadingResult(BaseResponseBean<UserInfo> entity) {
                mView.onUserInfo(entity.getData());
            }
        }, new OnLoadingErrorListener() {
            @Override
            public void onError(ApiException e, String method) {

            }

            @Override
            public void onErrorResult(BaseResponseBean entity, String method) {

            }
        }, "onUserInfo"));
    }

}